//
//  LWX_VideoModel.m
//  Otaku
//
//  Created by lanou3g on 16/5/7.
//  Copyright © 2016年 Liuwx. All rights reserved.
//

#import "LWX_VideoModel.h"

@implementation LWX_VideoModel

- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"id"]) {
        self.ID = value;
    }
    
    if ([key isEqualToString:@"group"]) {
        [self setValuesForKeysWithDictionary:value];
    }
    
    
}

- (CGFloat)cellHeight {
    CGSize maxSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - 2 * 10, MAXFLOAT);
    CGFloat textHeight = [self.text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil].size.height;
    _cellHeight = 10 + textHeight + 50;
    
    //videoImageview的高度
    CGFloat videoX = 0;
    CGFloat videoY = 50 + textHeight + 50;
    CGFloat videoWidth = [UIScreen mainScreen].bounds.size.width;

    CGFloat h = [self.group[@"360p_video"][@"height"] floatValue];
    CGFloat w = [self.group[@"360p_video"][@"width"] floatValue];
   
    CGFloat videoHeight = h * videoWidth / w;

    self.videoFrame = CGRectMake(videoX, videoY, videoWidth, videoHeight);
    _cellHeight += videoHeight + 50 + 50;
    return _cellHeight;
}


- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
    
}



@end
